﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for ManageBasket
/// </summary>
public class ManageBasket
{
	public ManageBasket()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static Basket_session Basket
    {
        get
        {
            if (HttpContext.Current.Session["Basket"] == null)
            {
                HttpContext.Current.Session["Basket"] = new Basket_session();

            }
            return (Basket_session)HttpContext.Current.Session["Basket"];
        }
    }

    /// <summary>
    /// Total price
    /// </summary>
    public static float SummaryCost
    {
        get { return Basket.Summary; }
    }

    /// <summary>
    /// Amount of products in basket
    /// </summary>
    public static int Count
    {
        get { return Basket.Count; }
    }

    public static List<OrderProduct> ListProduct()
    {
        return Basket.ListProduct;
    }
    public static OrderProduct GetProductFromBasket(string _productID)
    {
        return Basket.GetProductFromBasket(_productID);
    }
    public static DataTable GetProductFromDataBase(string basketID)
    {
        Basket_session bk = new Basket_session();
        return bk.GetProductFromDatabase(basketID);
    }
    public static void InsertProductToBasket(OrderProduct _product)
    {
        Basket.InsertProductToBasket(_product);
    }
    public static void DeleteProductFromBasket(OrderProduct _product)
    {
        Basket.DeleteProductFromBasket(_product);
    }
    public static void UpdateProductFromBasket(OrderProduct _oldProduct, OrderProduct _newProduct)
    {
        Basket.UpdateProductFromBasket(_oldProduct, _newProduct);
    }
    public static void InsertProductIntoTable(string Inv_ID)
    {
        if (Basket.ListProduct == null || Basket.ListProduct.Count == 0) return;
        Basket.InsertProductIntoTable(Inv_ID);
    }
}
